package fr.cdj.thebox.server;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;

import fr.cdj.thebox.client.services.FileAdminService;
import fr.cdj.thebox.server.generated.GeneratedConf;

public class FileAdminServiceImpl extends RemoteServiceServlet implements FileAdminService {

	private static final long serialVersionUID = -6728415650808484495L;

	@Override
	public void deleteFiles(String[] paths) {
		GeneratedConf gConf = XmlLoader.generateConfFromXmlFile();
		FileManager fm = new FileManager(gConf);
		if (gConf.isDelete()) {
			for (String path : paths) {
				fm.deleteFile(fm.getFileFromPath(path));
			}
		}
	}

	@Override
	public void createUser(String login, boolean isAdmin) {
		// TODO db insert
		System.out.println("CREATE login=" + login + " admin=" + isAdmin);
	}

	@Override
	public void deleteUser(String login) {
		// TODO db delete
		System.out.println("DELETE login=" + login);
	}

}
